package fr.mehfile.view;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import fr.mehfile.R;
import fr.mehfile.timetable.TimeTableAlarmManager;
import fr.mehfile.timetable.TimeTableModel;
import fr.mehfile.view.utils.Utils;

public class TimeTableTab  extends Activity{
	
	
	@Override
	public void onCreate(Bundle icicle) {
		super.onCreate(icicle);
		setContentView(R.layout.tab_timetable);
		setTimeTableValues();
	}
	
	private void setTimeTableValues() {
		String dayTimeTable = this.getIntent().getStringExtra("day");
		TimeTableModel timeTableModel = new TimeTableModel(dayTimeTable);
		
		TextView textFirstDate = (TextView) findViewById(R.id.timetableDate);
		textFirstDate.setText(timeTableModel.getLibelleDate());
		
		
		final TimeTableAlarmManager ttam = new TimeTableAlarmManager(getApplicationContext(),timeTableModel);
		TextView textTime = (TextView) findViewById(R.id.timetableFajr0);
		textTime.setText(timeTableModel.getFajr());
		/*final ImageView fajrImageAlarm = (ImageView) findViewById(R.id.alarmFajr);
		if(ttam.isFajr()){
			fajrImageAlarm.setImageResource(R.drawable.next_icon_button_pressed);
		}
		else{
			fajrImageAlarm.setImageResource(R.drawable.next_icon_button_normal);
		}
		fajrImageAlarm.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				if(ttam.isFajr()){
					fajrImageAlarm.setImageResource(R.drawable.next_icon_button_normal);
					ttam.setFajr(false);
				}
				else{
					fajrImageAlarm.setImageResource(R.drawable.next_icon_button_pressed);
					ttam.setFajr(true);
				}
			}
		});*/
		
		
		
		textTime = (TextView) findViewById(R.id.timetableLeverDuSoleil0);
		textTime.setText(timeTableModel.getLeverDuSoleil());
		/*final ImageView leverSoleilImageAlarm = (ImageView) findViewById(R.id.alarmLeverSoleil);
		if(ttam.isLeverSoleil()){
			leverSoleilImageAlarm.setImageResource(R.drawable.next_icon_button_pressed);
		}
		else{
			leverSoleilImageAlarm.setImageResource(R.drawable.next_icon_button_normal);
		}
		leverSoleilImageAlarm.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				if(ttam.isLeverSoleil()){
					leverSoleilImageAlarm.setImageResource(R.drawable.next_icon_button_normal);
					ttam.setLeverSoleil(false);
				}
				else{
					leverSoleilImageAlarm.setImageResource(R.drawable.next_icon_button_pressed);
					ttam.setLeverSoleil(true);
				}
			}
		});*/
		
		
		
		textTime = (TextView) findViewById(R.id.timetableZohr0);
		textTime.setText(timeTableModel.getZohr());
		/*final ImageView zohrImageAlarm = (ImageView) findViewById(R.id.alarmZohr);
		if(ttam.isZohr()){
			zohrImageAlarm.setImageResource(R.drawable.next_icon_button_pressed);
		}
		else{
			zohrImageAlarm.setImageResource(R.drawable.next_icon_button_normal);
		}
		zohrImageAlarm.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				if(ttam.isZohr()){
					zohrImageAlarm.setImageResource(R.drawable.next_icon_button_normal);
					ttam.setZohr(false);
				}
				else{
					zohrImageAlarm.setImageResource(R.drawable.next_icon_button_pressed);
					ttam.setZohr(true);
				}
			}
		});*/
		
		
	
		textTime = (TextView) findViewById(R.id.timetableCoucherDuSoleil0);
		textTime.setText(timeTableModel.getCoucherDuSoleil());
		/*final ImageView coucherSoleilImageAlarm = (ImageView) findViewById(R.id.alarmCoucherSoleil);
		if(ttam.isCoucherSoleil()){
			coucherSoleilImageAlarm.setImageResource(R.drawable.next_icon_button_pressed);
		}
		else{
			coucherSoleilImageAlarm.setImageResource(R.drawable.next_icon_button_normal);
		}
		coucherSoleilImageAlarm.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				if(ttam.isCoucherSoleil()){
					coucherSoleilImageAlarm.setImageResource(R.drawable.next_icon_button_normal);
					ttam.setCoucherSoleil(false);
				}
				else{
					coucherSoleilImageAlarm.setImageResource(R.drawable.next_icon_button_pressed);
					ttam.setCoucherSoleil(true);
				}
			}
		});*/


		
		textTime = (TextView) findViewById(R.id.timetableMagrib0);
		textTime.setText(timeTableModel.getMagrib());
		/*final ImageView magribImageAlarm = (ImageView) findViewById(R.id.alarmMagrib);
		if(ttam.isMagrib()){
			magribImageAlarm.setImageResource(R.drawable.next_icon_button_pressed);
		}
		else{
			magribImageAlarm.setImageResource(R.drawable.next_icon_button_normal);
		}
		magribImageAlarm.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				if(ttam.isMagrib()){
					magribImageAlarm.setImageResource(R.drawable.next_icon_button_normal);
					ttam.setMagrib(false);
				}
				else{
					magribImageAlarm.setImageResource(R.drawable.next_icon_button_pressed);
					ttam.setMagrib(true);
				}
			}
		});*/
		
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
	}

}
